#include <iostream>
using namespace std;
#define MaxWindows 25
#define MaxCustomers 2005
class Server{
private:
    int customer_num;
    int waiting_time[MaxCustomers];
    int out_time[MaxCustomers];
    int Queue[MaxWindows][MaxCustomers];
    int windows_num;
    int max_capacity;
    int front[MaxWindows];
    int rear[MaxWindows];
    int dequeue_time[MaxWindows];
public:
    Server(int num1,int num2,int num3){
        windows_num=num1;
        max_capacity=num2;
        customer_num=num3;
        for(int i=1;i<=customer_num;i++){
	    cin>>waiting_time[i];
	    out_time[i]=0;
        }
        for(int i=1;i<=windows_num;i++){
	    front[i]=rear[i]=1;
	    dequeue_time[i]=0;
	}
    }
    int isfull();
    int isempty();
    void enqueue(int customer);
    void dequeue();
    void check(int checknum);
    void print_time(int time){
	int hour;
	int minute;
	hour=time/60+8;
	minute=time%60;
	if(time>540){
	    cout<<"Sorry"<<endl;
	}else{
	    if(hour<10){
		cout<<"0"<<hour<<":";
	    }else{
		cout<<hour<<":";
	    }
	    if(minute==0){
		cout<<"00";
	    }else if(minute>0&&minute<10){
		cout<<"0"<<minute;
	    }else{
		cout<<minute;
	    }
	    cout<<endl;
	}
    }
};
//Judge if the queue is full,0 means false and 1 means true
int Server::isfull(){
    for(int i=1;i<=windows_num;i++){
        if(rear[i]-front[i]!=max_capacity){//ith queue isn't full
	return 0;
        }
    }
    return 1;
}
//Judge if the queue is empty,0 means false and 1 means true
int Server::isempty(){
    for(int i=1;i<=windows_num;i++){
	if(rear[i]!=front[i]){
	return 0;
	}
    }
    return 1;
}
void Server::enqueue(int customer){
    int nowcapacity;
    nowcapacity=rear[1]-front[1];
    int flag=1;
    if(isfull()==1){//FULL
        dequeue();
        enqueue(customer);
    }else{//Not FULL
        for(int i=1;i<=windows_num;i++){
	    if(rear[i]-front[i]<nowcapacity){
		nowcapacity=rear[i]-front[i];
		flag=i;
            }
	}
	Queue[flag][rear[flag]++]=customer;
    }
}
void Server::dequeue(){
    int s=1;
    int flag=1;//mark the 1st line
    int time;
    while(front[s]==rear[s]){
	s++;
    }//empty sequence can't dequeue!
    time=waiting_time[Queue[s][front[s]]]+dequeue_time[s];
    flag=s;
    for(int i=s;i<=windows_num;i++){
	if((waiting_time[Queue[i][front[i]]]+dequeue_time[i])<time){
	    time=waiting_time[Queue[i][front[i]]]+dequeue_time[i];
	    flag=i;
	}
    }//the flag's line dequeue!
    dequeue_time[flag]+=waiting_time[Queue[flag][front[flag]]];
    out_time[Queue[flag][front[flag]]]=dequeue_time[flag];
    front[flag]++;
}
void Server::check(int checknum){
    for(int i=1;i<=customer_num;i++){
	enqueue(i);
    }
    while(!isempty()){
	dequeue();
    }
    int num;
    for(int i=0;i<checknum;i++){
	cin>>num;
	print_time(out_time[num]);
    }
}
int main(){
    int num1,num2,num3,num4;
    cin>>num1>>num2>>num3>>num4;
    Server S(num1,num2,num3);
    S.check(num4);
}
